home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / arc2tarz < prev    next >
Encoding:
Korn shell script  |  1997-08-26  |  1.3 KB  |  47 lines

  1. #!/bin/ksh
  2. # arc2tarz: convert arced file to tarred, compressed form.
  3. # @(#) arc2tarz.ksh 1.0 96/01/19
  4. # 91/03/28 john h. dubois iii (john@armory.com)
  5. # 92/02/16 added -h option for help
  6. # 96/01/19 Exit if can't make tmpdir.
  7.  
  8. unset ENV
  9.  
  10. if [ $# = 0 -o "$1" = -h ]; then
  11.     echo \
  12. "Usage: $0 arcfile [ tarzfile ]
  13. arcfile is the name of an arc file to convert to tarred, compressed form. 
  14. The file must have a .arc extension, but only the base name needs to be
  15. given.  If no output file name is given, it will be created in the current
  16. directory with the name being the arcfile basename followed by .tar.Z
  17. If the basename is too long the extension may be truncated.  All upper
  18. case letters in the names of files in the archive are moved to lower case."
  19.     exit
  20. fi
  21.  
  22. [ -z "$TMP" ] && tmpdir=/tmp/arc2tarz.$$ || tmpdir=$TMP/arc2tarz.$$
  23.  
  24. [[ $1 != *.arc ]] && arcfile=$1.arc || arcfile=$1
  25. if [ ! -f $arcfile -o ! -r $arcfile ]; then
  26.     echo "Could not open arc file \"$arcfile\"."
  27.     exit 1
  28. fi
  29. [[ $arcfile != /* ]] && arcfile=$PWD/$arcfile
  30.  
  31. basename=${arcfile%.arc}
  32. basename=${basename##*/}
  33. [ $# -lt 2 ] && tarzname=$PWD/$basename.tar.Z || tarzname=$2
  34.  
  35. mkdir $tmpdir || {
  36.     print -u2 "Could not make tmpdir $tmpdir; exiting."
  37.     exit 1
  38. }
  39. cd $tmpdir
  40. echo "unarcing files..."
  41. arc -ie $arcfile
  42. lcase
  43. echo "tarring/compressing files..."
  44. tar cf - * | compress > $tarzname
  45. cd -
  46. rm -r $tmpdir
  47.